package com.academy.querystapp;
//Developed by Siva E on 30th Nov 2012
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.Window;

public class SplashActivity extends Activity 
{
		protected boolean _active = true;
		protected int _splashTime = 1000;
		
		@Override
		public void onCreate(Bundle savedInstanceState) 
		{
			super.onCreate(savedInstanceState);
			requestWindowFeature(Window.FEATURE_NO_TITLE);
			setContentView(R.layout.splashscreen);
//        	// thread for displaying the SplashScreen
			Thread splashTread = new Thread() 
			{
			
				public void run()
				{
					try
					{
						int waited = 0;
						while(_active && (waited < _splashTime))
						{
							sleep(1000);
							if(_active)
							{
								waited += 100;
							}
						}
					} 
					catch(InterruptedException e) 
					{
                    // do nothing
					} 
					finally 
					{
                		startActivity(new Intent(SplashActivity.this,HomeActivity.class));
                		finish();
//                		stop();                		
					}
				}
			};
			splashTread.start();

		}    
		@Override
		public boolean onTouchEvent(MotionEvent event)
		{
			if (event.getAction() == MotionEvent.ACTION_DOWN)
			{
				_active = false;
			}
			return true;
		}		
}

